/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package onpu_dms_xls.kernel;

import java.io.File;
import java.sql.Connection;
import onpu_dms_xls.exceptions.MyException;
import onpu_dms_xls.kernel.common.logAndDebug.LoggingFacade;
import org.apache.log4j.Logger;

/**
 *
 * @author Анатолий
 */
public abstract class TemplatesLoader {
    

    public enum TemplatesLoaderFiles {
        XLS_FILE("X", ".xls"),XML_FILE("T",".xml"), PDF_FILE("X", ".pdf");

        private String DB_Appendix;
        private String fileEnding;

        private TemplatesLoaderFiles(String dbAppendix, String fileEnding) {
            this.DB_Appendix = dbAppendix;
            this.fileEnding = fileEnding;
        }

        public String getDBAppendix (){
            return this.DB_Appendix;
        }

        public String getFileEnding(){
            return this.fileEnding;
        }
    }

    public enum TemplatesLoaders{
        DB, FILE;
    }
    
    /**
     requiredFile - DB or FILE
     */
    public static TemplatesLoader getTemplatesLoader(TemplatesLoaders requiredTemplateLoader){
        LoggingFacade.trace.trace("getTemplatesLoader call, requiredTemplateLoader="+requiredTemplateLoader);
        switch (requiredTemplateLoader){
            case DB : return new DBTemplatesLoader();
            case FILE : return new FileTemplatesLoader();
            default : throw new RuntimeException("wrong requiredTemplateLoader in "+Thread.currentThread().toString());
        }
    }


    public void loadTemplates(
            Connection con,
            File xlsTemplate,
            File xmlTemplate,
            int documentClassId,
            int userId) throws MyException{};

    public File getTemplateFile(
            String temporaryFolder,
            int documentClassId,
            Connection conn,
            TemplatesLoaderFiles fileType) throws MyException{ return null; };
}
